# -*- coding:Utf-8 -*-
'''
Created on 25 nov. 2012

@author: fefoley
'''
import codecs


input_root_path = "C:\\Users\\famille\\Desktop\\analyses mails\\reverse_hours.io\\"
path2f1 = input_root_path + 'brut holiday.txt'
path2f2 = input_root_path + 'net holiday.txt'

def convertdate(path2f1, path2f2):

    f1 = open(path2f1, 'r')
    f2 = open(path2f2, 'w')
    
    months = ['Janvier', 'Février','Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']
    
    for line in f1:
        linesplit = line.split('\t')
        strdate, strferie = linesplit[:2]
        nomjour, nbjour, nommois, annee = strdate.split()
        nbmois = months.index(nommois) + 1
        strout = "{0:02d}/{1:02d}/{2:d}\t{3}\n".format(int(nbjour), int(nbmois), int(annee), strferie)
        f2.write(strout)
        
    f1.close()
    f2.close()
    
class Str2sum:
    """a simple string "label" with a concatenation character "concat".   """
    def __init__(self, label, concat=' + '):
        self.label = label
        self.concat = concat
        
    def __add__(self, other):
        if self.label == other.label:
            return Str2sum(self.label, self.concat)
        else:
            return Str2sum(self.label + self.concat + other.label, self.concat)
    
    def __sub__(self, other):
        if self.label == other.label:
            return Str2sum("", self.concat)
        else:
            return Str2sum(self.label + " - " + other.label, self.concat)   #########   TMP
        
    def __xor__(self, other):
        if self.label == other.label:
            return Str2sum("", self.concat)
        else:
            return Str2sum(self.label + " ^ " + other.label, self.concat)   #########   TMP
           
    def __str__(self):
        return self.label.__str__()
    
    def __repr__(self):
        return self.label.__repr__()


if __name__ == "__main__":
    f = open(input_root_path + 'tmp.txt')
    
    line = f.readline()
    print("line: " +line)
    uline = codecs.encode(line)
    print("uline: "+str(uline))
